import matplotlib
import matplotlib.pyplot as plt
import numpy as np


# 显示柱状图,只需要替换count即可,之前的first.py~tenth.py都是输出的每个区段的占比,直接将输出的那个list复制过来替换count即可
# 这里的count画的是百分数的或者说是小数,需要显示%,所以要乘以100
# 下面还需要自己修改输出图片或者说是存储图片的文件名
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

width = 0.8
count=[0.9113885428055634, 0.06021002313814234, 0.018129115919550458, 0.0059498080296981875, 0.0021358285234814004, 0.0014238856823209336, 0.0003559714205802334, 0.0002288387703730072, 7.627959012433573e-05, 0.00010170612016578098]

count=np.array(count)*100
x_count=[i-0.1 for i in range(len(count))]
# x_count=range(1,len(count)+1)
x_label=['%d%%'%i for i in range(10,101,10)]


fig, ax = plt.subplots()
ax.bar(x_count,count,width = width,align='center',color = 'c',alpha=0.8)
plt.xlabel('相似度变化区间',fontsize=13)
plt.ylabel('占比(%)',fontsize=13)
plt.xlim((-0.6, 10-width))
x_label_count=[i+width/2 for i in range(len(count))]
plt.xticks(x_label_count,x_label,fontsize=11)


for a,b in enumerate(count):
    plt.text(a-0.1, b, '%.2f' % b, ha='center', va= 'bottom',fontsize=11)
fig.tight_layout()
plt.savefig('./result/ninth1.png', dpi=300)
plt.show()
